<? 
	$cur_folder = $this->getCurrentFolder();
	$rootDir = !isset($dir);
	
	global $resource_folder_index;
	if (!strlen($resource_folder_index))
		$resource_folder_index = 1;
	
	if (!isset($level))
		$level = 1;

	if ($rootDir): 
?>
	<ul>
		<li class="even <?= $cur_folder == PATH_APP.'/resources' ? 'current' : null ?>">
			<div class="item">
				<span class="folder_item">
					<a href="#" onclick="return $('FormElement').sendPhpr('index_onNavigate', {loadIndicator: {show:false}, onBeforePost: LightLoadingIndicator.show.pass('Loading...'), onComplete: LightLoadingIndicator.hide,  extraFields: {dir: '<?= '/resources' ?>'}});"><?= 'resources' ?></a>	
				</span>
				<div class="clear"></div>
			</div>
		</li>
<? endif ?>
	<?
		if (!isset($dir))
			$dir = '/resources';
		
		$relative_dir = $dir;
		$dir = PATH_APP.$dir;

		if (is_dir($dir))
		{
			if ($dh = opendir($dir))
			{
				while ( ($file = readdir($dh)) !== false )
				{
					$dir_path = $dir.'/'.$file;
					if ($file == '.' || $file == '..' || !is_dir($dir_path) || ($file == '.svn'))
						continue;
					
					$resource_folder_index++;

				?>
					<li class="<?= $resource_folder_index % 2 ? 'even' : null ?> <?= $cur_folder == $dir_path ? 'current' : null ?>">
						<div class="item" style="padding-left: <?= 15*$level ?>px">
							<span class="folder_item">
								<a href="#" onclick="return $('FormElement').sendPhpr('index_onNavigate', {loadIndicator: {show:false}, onBeforePost: LightLoadingIndicator.show.pass('Loading...'), onComplete: LightLoadingIndicator.hide, extraFields: {dir: '<?= $relative_dir.'/'.$file ?>'}});"><?= h($file) ?></a>
							</span>
							<div class="clear"></div>
						</div>
					</li>
					
					<? $this->renderPartial('folder_list', array('dir'=>$relative_dir.'/'.$file, 'level'=>$level+1)) ?>
				<?
				}
				closedir($dh);
			}
		}
	?>
	
<? if ($rootDir): ?>
	</ul>
<? endif ?>
